import React from 'react';
import FormatValue from '../../../components/formatValue';
import { Row, Col } from 'antd';

const ReturnValue = ({ value }) => {
  const { returningType, returningTypeLabel, successExample, failedExample } = value;

  const getDetailList = () => [
    {
      label: '返回类型',
      value: returningTypeLabel,
    },
    {
      label: '返回值成功示例',
      value: <FormatValue type={returningType} data={successExample} />,
    },

    {
      label: '返回值失败示例',
      value: <FormatValue type={returningType} data={failedExample} />,
    },
  ];
  return (
    <>
      <Row>
        {getDetailList().map(({ label, value }, index) => (
          <Col span={24} style={{ marginBottom: '20px' }} key={index}>
            <Row>
              <Col span={4}>{label}</Col>
              <Col span={20}>{value || '-'}</Col>
            </Row>
          </Col>
        ))}
      </Row>
    </>
  );
};
export default ReturnValue;
